package cn.mifengkong.appcommon.webview.jshandler;

import android.content.Context;
import android.text.TextUtils;

import com.mifengkong.frtools.jsbridge.CallBackFunction;
import com.mifengkong.frwidget.titlebar.WebViewTitleBarUIComponent;

import cn.mifengkong.appcommon.webview.listener.JsBridgeCallBackListener;
import cn.mifengkong.appcommon.webview.uicomponent.WebViewUIComponent;

/**
 * Created by jiang on 2018/3/6
 *
 * @author fengrong
 *         设置右上角的图片按钮与rightBtn的效果功能差不多
 */

public class NavButtonHandler extends CustomeWebviewTitleHandler {


    public NavButtonHandler(Context context, WebViewUIComponent webViewUIComponent, WebViewTitleBarUIComponent titleBarUIComponent, String applicationId, JsBridgeCallBackListener jsBridgeCallBackListener) {
        super(context, webViewUIComponent, titleBarUIComponent, applicationId, jsBridgeCallBackListener);
    }

    @Override
    protected void setImageToView(String iconUrl, String jumpUrl, String text, IvOnclickListener ivOnclickListener) {
        if (TextUtils.isEmpty(iconUrl) || TextUtils.isEmpty(jumpUrl)) {
            mWebViewTitleBarUIComponent.removeRightImageViewLeftToRefreshBg();
            return;
        }
        mWebViewTitleBarUIComponent.setRightImageViewLeftToRefresh(iconUrl, ivOnclickListener);
    }

    @Override
    public void OnHandler(String handlerName, String responseData, CallBackFunction function) {
        parseResponseData(responseData, function);
    }


}
